package com.cs.study.homework._0227;

import java.util.Objects;

public class Demo3 {
    public static void main(String[] args) {
        Animal dog = new Animal();
        Animal cat = new Animal();
        System.out.println(dog.equals(cat));
        System.out.println(cat.equals(dog));
    }

}

class Animal {
    int age;
    String name;
    double price;

    public Animal(int age, String name, double price) {
        this.age = age;
        this.name = name;
        this.price = price;
    }

    public Animal() {
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Animal animal = (Animal) o;
        return age == animal.age && Double.compare(animal.price, price) == 0 && Objects.equals(name, animal.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(age, name, price);
    }
}
